package it.eng.area118.mdogpscollector.util;

import it.eng.area118.mdogpscollector.InsertCheckPointActivity;
import it.eng.area118.mdogpscollector.ViewPagerExample;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;

public class ViewUtils {

	public static <E extends View> E getView(Activity a, int id) {
		return (E) a.findViewById(id);
	}

	public static <E extends View> E getView(View a, int id) {
		return (E) a.findViewById(id);
	}

	public static void doFragmentTransaction(FragmentManager manager, int sourceRef, Fragment destinationObj) {
		FragmentTransaction tr = manager.beginTransaction();
		tr.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
		tr.replace(sourceRef, destinationObj).commit();
	}

	public static void doActivityChange(Context context, Class<?> activityClass) {
		Intent detailIntent = new Intent(context, activityClass);
		context.startActivity(detailIntent);
	}

	public static void doActivityChange(Context context, Intent intent) {
		context.startActivity(intent);
	}
}
